<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

App::uses('AppController', 'Controller');

class GestionsController extends AppController {
var $name = 'Gestions';
	
	

      
	public function index() {
		$this->Gestion->recursive = 0;
		$gestions = $this->Gestion->find('all');
	$this->set('gestions', $this->paginate());
	

	
	
	}
		
		public function view($id = null) {
		$this->Gestion->id = $id;
		if (!$this->Gestion->exists()) {
			throw new NotFoundException(__('Gestion no v�lido'));
		}
		$this->set('gestion', $this->Gestion->read(null, $id));
	}

	public function add() {
		if ($this->request->is('post')) {
			$this->Gestion->create();
			if ($this->Gestion->save($this->request->data)) {
				$this->Session->setFlash(__('El Gestion ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('Gestion no puede ser guardado. Intente otra vez.'));
			}
		}
	}
	
	
		public function edit($id = null) {
		$this->Gestion->id = $id;
		if (!$this->Gestion->exists()) {
			throw new NotFoundException(__('Gestion Invalido'));
		}
		if ($this->request->is('post') || $this->request->is('put')) {
			if ($this->Gestion->save($this->request->data)) {
				$this->Session->setFlash(__('Gestion ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('Gestion no puede ser guardado. Intente otra vez.'));
			}
		} else {
			$this->request->data = $this->Gestion->read(null, $id);
		}
	}
	
        
        
	public function delete($id = null) {
		if (!$this->request->is('post')) {
			throw new MethodNotAllowedException();
		}
		$this->Gestion->id = $id;
		if (!$this->Gestion->exists()) {
			throw new NotFoundException(__('Gestion no v�lido'));
		}
		if ($this->Gestion->delete()) {
			$this->Session->setFlash(__('Gestion eliminado'));
			$this->redirect(array('action' => 'index'));
		}
		$this->Session->setFlash(__('Gestion no fue eliminado'));
		$this->redirect(array('action'  => 'index'));
	}
	}
        
